(in-package :experiment)

(defvar *triple-dropout-remaining* nil
  "A variable to access how many trials remain in the dropout.")

(defvar *triple-dropout-block* nil
  "A variable to access how many iterations have gone by in the dropout..")

(defclass triple-dropout (subsequence)
  ())

(defmethod state-run (experiment (state triple-dropout))
  (loop
     :for *triple-dropout-block* :below 3 :do
     (let ((*triple-dropout-remaining* (u:randomize-list (subsequence-children state))))
       (loop :while *triple-dropout-remaining* :do
	  (dolist (i *triple-dropout-remaining*)
	    (when (state-run experiment i)
	      (setf *triple-dropout-remaining* (remove i *triple-dropout-remaining*))))
	  (setf *triple-dropout-remaining* (u:randomize-list *triple-dropout-remaining*))))))

(defmethod compile-state (experiment (state (eql 'triple-dropout)) args)
  (make-instance 'triple-dropout
		 :parent experiment
		 :children (mapcar (lambda (x) (compile-state experiment (car x) (cdr x)))
				   args)))
